//
//  AppDelegate+AppService.m
//  InTube
//
//  Created by seven on 2019/10/29.
//  Copyright © 2019 seven. All rights reserved.
//

#import "AppDelegate+AppService.h"
//#import "AppDelegate+Push.h"

//#import <IconFont/TBCityIconFont.h>
#import "ITMJRefreshHeadGifImagesTool.h"
#define IconfontGoBackDefaultSize 18
#define ThemeHexColor @"#FFFFFF"
#import "ITLocationManager.h"
//#import <FirebaseCore/FIRApp.h>
//#import <FirebaseCrashlytics/FirebaseCrashlytics.h>
//#import <FBSDKCoreKit/FBSDKCoreKit.h>
//#import <Branch/Branch.h>
#import "ITNetworkMonitorManager.h"


@implementation AppDelegate(AppService)

- (void)thirdSetting:(NSDictionary * _Nullable)launchOptions{
    ITAppStartManager.shareManager.launchOptions = launchOptions;
    //return;
    [self setNavBarAppearence];
    [self setToastAppearence];
    
    [[ITLocationManager shareManager] startLocationService];
    if (ITUserManager.currentMember == nil) {
        [ITUserManager.shareManager activeDevice:nil];
    }
    
    [ITAppStartManager.shareManager startApp];
    
    GlobalDelay(0, ^{
        NSString *idf  = [ITDeviceInfo idfa];
        [ITNetworkMonitorManager.shareManager startMonitorNetwork];
        [ITTrackManager.shareManager startApp];
    });
    
    //[self startPushService:NO];
    //[ITOrientationManager.sharedInsatnce startListeningDirectionOfDevice];
    
#if DEBUG
    [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle"] load];
#endif

}


//*/
- (void)setToastAppearence{

    CSToastStyle *style = [[CSToastStyle alloc] initWithDefaultStyle];
    style.titleFont = SemiboldFontWithSize(16);
    style.messageFont = SemiboldFontWithSize(16);
    style.verticalPadding = 20;
    style.titleAlignment = NSTextAlignmentCenter;
    style.messageAlignment = NSTextAlignmentCenter;
    
    [CSToastManager setDefaultDuration:2];
    [CSToastManager setSharedStyle:style];
    [CSToastManager setDefaultPosition:CSToastPositionCenter];
}

#pragma mark - WRNavigationBar
- (void)setNavBarAppearence
{
    

    [ITMJRefreshHeadGifImagesTool gifImagesWithGif:@"RefreshHead"];
    UITabBar.appearance.tintColor = ColorWithHex(0xF9FAF9);
    
    //[TBCityIconFont setFontName:@"iconfont"];
    
    UIImage *backImage = [UIImage imageNamed:@"Default_back"];
    [[UINavigationBar appearance] setTintColor:COLOR_333333];
    [[UINavigationBar appearance] setBackIndicatorImage:backImage];
    [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:backImage];
    //[[UINavigationBar appearance] setShadowImage:UIImage.new];
    //[[UINavigationBar appearance] setBackIndicatorImage:[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e606", IconfontGoBackDefaultSize, ColorWithString(ThemeHexColor))]];
    //[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e606", IconfontGoBackDefaultSize, ColorWithString(ThemeHexColor))]];
    //    [[UITabBar appearance] setTintColor:[UIColor colorFromString:@"#3281F8"]];
    //    [[UITabBar appearance] setUnselectedItemTintColor:[UIColor colorFromString:@"#4A4A4A"]];
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-CGFLOAT_MAX, 0) forBarMetrics:UIBarMetricsDefault];

//    [[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];
//    [[UITabBar appearance] setBackgroundColor:ColorWithHex(0x1B1E3F)];
}


- (void)applicationWillEnterForeground:(UIApplication *)application{
    application.applicationIconBadgeNumber = 0;
}

@end
